package com.viphuli.fragment;

import java.util.List;

import android.support.v4.app.Fragment;
import android.text.Html;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.Bind;

import com.offroader.utils.StringUtils;
import com.viphuli.app.R;

public class HomeServiceInfoNeedKnowFragment extends BaseProgressFragment {
	
	@Bind(R.id.id_main_home_service_item_info_need_know_layout)
	protected ViewGroup needKnowLayout;
	
	@Bind(R.id.id_main_home_service_item_info_need_know)
	protected TextView needKnowText;

	private HomeServiceInfoFragment serviceInfoFrag;

	private String needKnow;

	@Override
	protected int obtainContentRes() {
		return R.layout.frag_home_service_need_know;
	}

	@Override
	protected void initParams() {

	}

	@Override
	protected void initView() {
		List<Fragment> fs = getFragmentManager().getFragments();
		serviceInfoFrag = (HomeServiceInfoFragment) fs.iterator().next();

//		needKnowText.setMovementMethod(ScrollingMovementMethod.getInstance());

		if (StringUtils.isNotBlank(needKnow))
			needKnowText.setText(needKnow);

		//顶部显示&隐藏控制
		serviceInfoFrag.setScrollTouchEvent(needKnowLayout);
	}

	@Override
	protected void initData() {

		List<Fragment> fs = getFragmentManager().getFragments();
		HomeServiceInfoFragment serviceInfoFrag = (HomeServiceInfoFragment) fs.iterator().next();

		if (serviceInfoFrag.getItemPage() != null) {
			String notice = serviceInfoFrag.getItemPage().getNotice();
			if (StringUtils.isNotBlank(notice))
				needKnowText.setText(Html.fromHtml(notice));
		}

	}

	public void setNeedKnow(String needKnow) {
		this.needKnow = needKnow;

		if (StringUtils.isNotBlank(needKnow))
			needKnowText.setText(Html.fromHtml(needKnow));
	}

}
